#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5,M=1e9;
long long n,m,l,r,a[N],ans,dp[N][N],o,root[N];
struct node{
	int l,r,mx;
}tree[N*N*20+5];
void xg(int l,int r,int nn,int z,int id)
{
	if(l==r)
	{
		tree[id].mx=max(z,tree[id].mx);
		return;
	}
	int mid=(l+r)/2;
	if(mid>=nn)
	{
		if(!tree[id].l) ++o,tree[id].l=o,tree[o].l=tree[o].r=tree[o].mx=0;
		xg(l,mid,nn,z,tree[id].l);
	}
	else{
		if(!tree[id].r) ++o,tree[id].r=o,tree[o].l=tree[o].r=tree[o].mx=0;
		xg(mid+1,r,nn,z,tree[id].r);
	}
	if(tree[id].l) tree[id].mx=max(tree[id].mx,tree[tree[id].l].mx);
	if(tree[id].r) tree[id].mx=max(tree[id].mx,tree[tree[id].r].mx);
}
int cz(int l,int r,int nl,int nr,int id)
{
	if(nl>nr) return 0;
	if(nl<=l&&r<=nr)
		return tree[id].mx;
	int mid=(l+r)/2,ans=0;
	if(mid>=nl&&tree[id].l) ans=max(ans,cz(l,mid,nl,nr,tree[id].l)); 
	if(mid<nr&&tree[id].r) ans=max(ans,cz(mid+1,r,nl,nr,tree[id].r));
	return ans;
}
bool cheak(long long mid)
{
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			dp[i][j]=0;
	for(int i=1;i<=n;++i)
		root[i]=i,tree[i].l=tree[i].r=tree[i].mx=0;
	o=n;
	for(int i=1;i<=n;++i)
	{
		dp[i][i]=1;
		xg(1,M,a[i],1,root[i]);
		for(int z=1;z<i;++z)
		{
			dp[i][z]=cz(1,M,1,mid-a[i],root[z])+1;
			xg(1,M,a[i],dp[i][z],root[z]);
		}
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			if(a[i]+a[j]<=mid&&dp[i][j]>=m)
				return 1;
	return 0;
}
int main()
{
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	l=1,r=2e9;
	while(l<=r)
	{
		long long mid=(l+r)/2;
		if(cheak(mid))
			r=mid-1,ans=mid;
		else
			l=mid+1;
	}
	cout<<ans;
	return 0;
}
